package com.dolittle.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class DolittleTestActivity extends Activity {
	/** Called when the activity is first created. */

	private final int LIST = 0;
	private final int EXIT = 1;
	private final int ADD = 2;
	private final int EDIT = 3;

	private WordListView mWordListView;
	private AddView mAddView;
	private WordList mList;
	private EditView mEditView;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mList = new WordList(this);
		mWordListView = new WordListView(this, mList,this);
		mAddView = new AddView(this, mList);
		mEditView = new EditView(this, mList);
		setContentView(mWordListView);
	}

	public boolean onCreateOptionsMenu(Menu menu) {
		menu.add(0, LIST, 0, "List");
		menu.add(0, ADD, 0, "Add");
		menu.add(0, EDIT, 0, "Edit");
		menu.add(0, EXIT, 0, "Exit");
		return true;
	}
	
	public void goToEdit(Word word){
		mEditView.setFrom(word);
		setContentView(mEditView);
	}

	public boolean onOptionsItemSelected(MenuItem item) {

		switch (item.getItemId()) {

		case LIST:
			setContentView(mWordListView);
			return true;
		case ADD:
			setContentView(mAddView);
			return true;
		case EDIT:
			setContentView(mEditView);
			return true;
		case EXIT:
			System.exit(1);
		}
		return false;

	}
}